package com.yisoo.ubag.product.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.yisoo.ubag.product.entity.ConBraSceEntity;
import com.yisoo.ubag.product.service.ConBraSceService;
import com.yisoo.common.utils.PageUtils;
import com.yisoo.common.utils.R;



/**
 * 
 *
 * @author mmciel
 * @email 761998179@qq.com
 * @date 2021-02-07 17:11:37
 */
@RestController
@RequestMapping("product/conbrasce")
public class ConBraSceController {
    @Autowired
    private ConBraSceService conBraSceService;


    //级联选择框所需要的品牌-场景结构
    @GetMapping("/tree/{cid}")
    public R tree(@PathVariable("cid")Long cid){
        return conBraSceService.getTree(cid);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("product:conbrasce:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = conBraSceService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{consumerId}")
    //@RequiresPermissions("product:conbrasce:info")
    public R info(@PathVariable("consumerId") Long consumerId){
		ConBraSceEntity conBraSce = conBraSceService.getById(consumerId);

        return R.ok().put("conBraSce", conBraSce);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("product:conbrasce:save")
    public R save(@RequestBody ConBraSceEntity conBraSce){
		conBraSceService.save(conBraSce);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("product:conbrasce:update")
    public R update(@RequestBody ConBraSceEntity conBraSce){
		conBraSceService.updateById(conBraSce);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("product:conbrasce:delete")
    public R delete(@RequestBody Long[] consumerIds){
		conBraSceService.removeByIds(Arrays.asList(consumerIds));

        return R.ok();
    }

}
